Here are some strange plot things we have done before
When at all possible:
annotation_raster())Reproducible and ultimately time-saving.
library(jpeg)
img <- readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))
P <- map(.x = 1:4,
.f = function(ii) {
ggplot() +
annotation_raster(img,
xmin = 0, xmax = dim(img)[2],
ymin = 0, ymax = dim(img)[1]) +
xlim(c(0, dim(img)[2])) +
ylim(c(0, dim(img)[1])) +
coord_equal() +
ggpubr::theme_transparent()
})
wrap_plots(P) +
plot_annotation(tag_levels = 'a', tag_suffix = ".")patchwork automatically handles axis alignmentcowplot::plot_grid() gives fine control over relative plot sizep1 <- ggplot(M, aes(x1, y1)) + geom_point() +
theme(axis.title.x = element_blank(), axis.text.x = element_blank())
p2 <- ggplot(M, aes(x2, y1)) + geom_point() +
theme(axis.title = element_blank(), axis.text = element_blank())
p3 <- ggplot(M, aes(x1, y2)) + geom_point()
p4 <- ggplot(M, aes(x2, y2)) + geom_point() +
theme(axis.title.y = element_blank(), axis.text.y = element_blank())
plot_grid(p1, p2, p3, p4)theme(legend.position = ...) for basic positioninglemon package for more optionsreposition_legendreposition_legendgrid.arrange()p1 <- ggplot(M, aes(x1, y1, color = y1)) + geom_point()
p2 <- ggplot(M, aes(x2, y1, color = y1)) + geom_point()
p3 <- ggplot(M, aes(x1, y2, color = y1)) + geom_point()
library(gridExtra)
legend <- g_legend(p1 + theme(legend.position = "bottom"))
grid.arrange(p1 + theme(legend.position = "hidden"),
p2 + theme(legend.position = "hidden"),
p3 + theme(legend.position = "hidden"),
legend)guides() and guide_legend()PP <- palmerpenguins::penguins |>
mutate(Penguin_label = paste0(species, "\npenguin"))
ggplot(PP |> drop_na(bill_length_mm, bill_depth_mm),
aes(bill_length_mm, bill_depth_mm, color = species)) +
geom_point(show.legend = FALSE) +
facet_grid(. ~ Penguin_label) +
cowplot::theme_cowplot(font_size = 10) +
theme(strip.background = element_blank(),
strip.text = element_text(face = "bold", size = rel(1.5)))